#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

int bin_search(int arr[], int left, int right, int num)
{

	while (left <= right)
	{	
		int mid = left + ((right - left) >> 1);

		if (arr[mid] < num)
		{
			left = mid + 1;
		}
		else if (arr[mid] > num)
		{
			right = mid - 1;
		}
		else
		{
			return mid;
		}
	}
	
	return -1;
}

int main()
{
	int arr[10] = { 0,1,2,3,4,5,6,7,8,9 };

	int len = sizeof(arr) / sizeof(arr[0]);

	int ret = bin_search(arr, 0, 9, 55);

	printf("%d\n", ret);

	return 0;
}